﻿namespace SsisLdapSource
{
    using System.Collections.Generic;

    using global::SsisLdapSource.DirectoryServicesProtocolsExtensions;

    // If Semantic groupings are not provided by the end user will create empty member to 
    // avoid null exceptions deeper in code 
    public partial class SsisLdapSource : ILdapMetaDataPropertiesContainer
    {
        public int MaxStringAllocationSize
        {
            get
            {
                return (int)ComponentMetaData.CustomPropertyCollection["MaxColumnSpaceAllocation"].Value;
            }
        }

        public Int64DateTimeEncodedAttributeGroup Int64EncodedAttributeDateTimeAttributes
        {
            get
            {
                if (ComponentMetaData.CustomPropertyCollection["Int64EncodedDateTimeAttributes"].Value != null)
                {
                    var attributeList =
                        new List<string>(
                            (string[])
                            ComponentMetaData.CustomPropertyCollection["Int64EncodedDateTimeAttributes"].Value);
                    return new Int64DateTimeEncodedAttributeGroup(attributeList);
                }

                return new Int64DateTimeEncodedAttributeGroup();
            }
        }

        public GuidEncodedAttributeGroup GuidEncodedAttributeBinaryAttributes
        {
            get
            {
                if (ComponentMetaData.CustomPropertyCollection["GuidEncodedBinaryAttributes"].Value != null)
                {
                    var attributeList = new List<string>(
                        (string[])ComponentMetaData.CustomPropertyCollection["GuidEncodedBinaryAttributes"].Value);
                    return new GuidEncodedAttributeGroup(attributeList);
                }

                return new GuidEncodedAttributeGroup();
            }
        }

        public SidEncodedAttributeGroup SidEncodedAttributeBinaryAttributes
        {
            get
            {
                if (ComponentMetaData.CustomPropertyCollection["SidEncodedBinaryAttributes"].Value != null)
                {
                    var attributeList = new List<string>(
                        (string[])
                        ComponentMetaData.CustomPropertyCollection["SidEncodedBinaryAttributes"].Value);
                    return new SidEncodedAttributeGroup(attributeList);
                }

                return new SidEncodedAttributeGroup();
            }
        }

        public StringEncodedIntAttributeGroup StringEncodedIntAttributes
        {
            get
            {
                if (ComponentMetaData.CustomPropertyCollection["StringEncodedIntAttributes"].Value != null)
                {
                    var attributeList = new List<string>(
                        (string[])
                        (ComponentMetaData.CustomPropertyCollection["StringEncodedIntAttributes"].Value));
                    return new StringEncodedIntAttributeGroup(attributeList);
                }

                return new StringEncodedIntAttributeGroup();
            }
        }
        public AttributesWhichMayRequireExpansionGroup AttributesWhichMayRequireExpansion
        {
            get
            {
                if (ComponentMetaData.CustomPropertyCollection["AttributesWhichMayRequireExpansion"].Value != null)
                {
                    var attributeList = new List<string>(
                        (string[])
                        (ComponentMetaData.CustomPropertyCollection["AttributesWhichMayRequireExpansion"].Value));
                    return new AttributesWhichMayRequireExpansionGroup(attributeList);
                }

                return new AttributesWhichMayRequireExpansionGroup();
            }
        }

    }
}
